const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        pageType: 0, //如果为0,是点击商品进入 为1,点击品牌进入
        items: [
            {
                text: "全部",
                id: 1
            },
            {
                text: "全部",
                id: 2
            },
            {
                text: "全部",
                id: 3
            },
            {
                text: "全部",
                id: 4
            },
            {
                text: "全部",
                id: 5
            },
            {
                text: "全部",
                id: 6
            },
            {
                text: "全部",
                id: 7
            },
            {
                text: "全部",
                id: 8
            },
            {
                text: "全部",
                id: 9
            },
            {
                text: "全部",
                id: 10
            },
            {
                text: "全部",
                id: 11
            },
            {
                text: "全部",
                id: 12
            }
        ],
        curTap: 1,
        secCurTap: 0,
        upDown: false,
        defalut: true,
        brandShops: {
            brandName: 'Dior/迪奥',
            brand: '日本品牌',
            num: 55,
            logoImg: '../../images/ping/dior.png'
        },
        scrollTop: 0,
        isFolded: true, //简介展开
        dataType: 1,
        dataArr: [ ]
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        let that = this;
        that.setData({
            pageType: options.type,
            dataArr:app.globalData.dataArr
        })
    },
    folded: function (e) {
        this.setData({
            isFolded: !this.data.isFolded
        })
    },
    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady: function () {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide: function () {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload: function (options) {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh: function () {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom: function () {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage: function () {

    },
    onPageScroll: function (e) {
        let that = this;
        that.setData({
            scrollTop: e.scrollTop
        })
        console.log(this.data.scrollTop)
    },
    tapSelected: function (e) {
        let that = this;
        let curId = e.currentTarget.dataset.id;
        that.setData({
            curTap: curId
        })
    },
    secondTapSelected: function (e) {
        let that = this;
        let curType = e.currentTarget.dataset.type;
        console.log(e.currentTarget.dataset.type)
        that.setData({
            secCurTap: curType
        })
    },
// 价格排序点击事件
    upDown: function () {
        let that = this;
        that.setData({
            upDown: !this.data.upDown,
            defalut: false,
        })
        console.log(this.data.upDown)
    },
    backPage: function (e) {
        wx.navigateBack();
    },

    play: function (e) {
        wx.showToast({ title: 'play' })
    },
    pause: function (e) {
        wx.showToast({ title: 'pause' })
    },
    ended: function (e) {
        wx.showToast({ title: 'ended' })
    },
    timeupdate: function (e) {
        console.log(e)
    },
    fullscreenchange: function (e) {
        console.log(e)
    },
    scrollY: function (e) {
        let that = this;
        that.setData({
            top: e.detail.scrollTop
        })
        console.log(this.data.top)
    },
    // 降序
    sorting: function (dataArr) {
        for (var i = 0; i < dataArr.length; i++) {
            for (var j = 0; j < dataArr.length - i - 1; j++) {
                if (parseFloat(dataArr[j]) < parseFloat(dataArr[i])) {
                    var data = dataArr[j];
                    dataArr[j] = dataArr[j + 1];
                    dataArr[j + 1] = data;
                }
            }
        };
        return dataArr
    }
})